package com.opengl.englishwars;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;

public class OpenGLES10SurfaceView extends GLSurfaceView {
	Context mContext;
	public OpenGLES10SurfaceView(Context context) {
		super(context);
		mContext = context;
	}

	public OpenGLES10SurfaceView(Context context, AttributeSet attrs) {
		super(context, attrs);
		mContext = context;
	}

	@Override
	public boolean onTouchEvent(MotionEvent e) {
		// MotionEvent reports input details from the touch screen
		// and other input controls. In this case, you are only
		// interested in events where the touch position changed.

		float x = e.getX();
		float y = e.getY();
		Log.i("Test", "maxY" + getHeight() + "x:" + x + ", y:" + y);

		if (x < 64 && y > getHeight() - 64) {
			Log.i("Test", "touched!!");
		}

		switch (e.getAction()) {
		case MotionEvent.ACTION_MOVE:

			// float dx = x - mPreviousX;
			// float dy = y - mPreviousY;

			// reverse direction of rotation above the mid-line
			if (y > getHeight() / 2) {
				// dx = dx * -1;
			}

			// reverse direction of rotation to left of the mid-line
			if (x < getWidth() / 2) {
				// dy = dy * -1;
			}

			requestRender();
		}

		// mPreviousX = x;
		// mPreviousY = y;
		return true;
	}
}
